package com.yunyao.dao.service.bamu.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunyao.common.constant.enums.DataDeletedStatus;
import com.yunyao.dao.model.BamuInvoice;
import com.yunyao.dao.mapper.BamuInvoiceMapper;
import com.yunyao.dao.model.BamuReconciliation;
import com.yunyao.dao.model.BamuReconciliationSettlement;
import com.yunyao.dao.service.bamu.IBamuInvoiceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 项目发票信息表 服务实现类
 * </p>
 *
 * @author xingjishuai
 * @since 2024-07-02
 */
@Service
public class BamuInvoiceServiceImpl extends ServiceImpl<BamuInvoiceMapper, BamuInvoice> implements IBamuInvoiceService {

    @Override
    public BamuInvoice getByIdNoDelete(String id) {
        // 验证ID有效性
        if (StringUtils.isBlank(id)) {
            return null;
        }
        // 构建查询条件，寻找ID为指定值且未被删除的采购合同记录
        LambdaQueryWrapper<BamuInvoice> wrapper =
                new LambdaQueryWrapper<BamuInvoice>()
                        .eq(BamuInvoice::getId, id)
                        .eq(BamuInvoice::getIsDeleted, DataDeletedStatus.NO.getType());
        // 执行查询并返回结果
        return getOne(wrapper);
    }

    @Override
    public List<BamuInvoice> listById(String Id) {
        // 检查合同ID是否为空或空白，如果是，则返回一个空列表
        if (org.apache.commons.lang3.StringUtils.isBlank(Id)) {
            return List.of();
        }
        // 创建一个LambdaQueryWrapper用于构建查询条件
        LambdaQueryWrapper<BamuInvoice> wrapper =
                new LambdaQueryWrapper<BamuInvoice>().eq(BamuInvoice::getId,
                        Id).eq(BamuInvoice::getIsDeleted, DataDeletedStatus.NO.getType());
        // 使用构建的查询条件获取并返回关联的材料列表
        return list(wrapper);
    }
}
